<?php
//connect to MySQL
$db = mysqli_connect('localhost','root','softdev3','eventsmanager_v31') or
                die ('cannot connect');
//change this path to match your images directory
$dir ='/var/www/eventsmanager/server/view/images';
//change this path to match your thumbnail directory
$thumbdir = '/var/www/eventsmanager/server/view/images/thumbs';



?>

<html>
<head>
<title>Welcome to our Photo Gallery</title>
<style type="text/css">
th { background-color: #999;}
.odd_row { background-color: #EEE; }
.even_row { background-color: #FFF; }
</style>
</head>
<body>
<p>Click on any image to see it full sized.</p>
<table style="width:100%;">
<tr>
<th>Image</th>
<th>Caption</th>
<th>Uploaded By</th>
<th>Date Uploaded</th>
</tr>
<?php
//get the thumbs

$result = $db->query('SELECT * FROM images') or die(mysqli_error($db));
$odd = true;
while ($rows = mysqli_fetch_array($result)) {
echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';
$odd = !$odd;
extract($rows);
echo '<td><a href="' . $dir . '/' . $image_id . '.jpg">';
//echo '<img src="' . $thumbdir . '/' . $image_id . '.jpg">';
$imagename = 'images/' . $image_id . '.jpg';
?>
<img src="<?php echo $imagename; ?>" style="float:left;">
<?php
echo '</a></td>';
echo '<td>' . $image_caption . '</td>';
echo '<td>' . $image_username . '</td>';
echo '<td>' . $image_date . '</td>';
echo '</tr>';
}
?>
</table>
</body>
</html>

